﻿using System;
using System.Collections.Generic;
using System.Linq;
using DTO;
using DA;
using System.Data;

namespace BLL
{
    public class ChiTietBaoBLL
    {
        private readonly ChiTietBaoDA DA =new ChiTietBaoDA();
        public DataSet GetAll()
        {
            return DA.GetAll();
        }


        public int GetID(ChiTietBaoDTO item)
        {
            return DA.GetID(item);
        }
        public string GetGiaTien(ChiTietBaoDTO item)
        {
            return DA.GetGiaTien(item);
              }
        public int Add(ChiTietBaoDTO item)
        {
            return DA.Add(item);
        }

        public bool Update(ChiTietBaoDTO item)
        {
            return DA.Update(item);
        }

        public bool Delete(int Ma_item)
        {
            return DA.Delete(Ma_item);
        }
        // load du liuieu
        public DataSet Load()
        {
            MyQueryDA myQueryDA = new MyQueryDA();
            const string query = "select MaChiTietBao,TenBao,TenMauSac,TenViTri,GiaTienBao from BAO,CHITIETBAO,VITRI,MAUSAC where BAO.MaBao=CHITIETBAO.MaBao and CHITIETBAO.MaMauSac=MAUSAC.MaMauSac and CHITIETBAO.MaViTri=VITRI.MaViTri";
            return myQueryDA.doQuery(query);
        }
        public int getMax_MaChiTietBao()
        {
            return DA.getMax_MaChiTietBao();
        }
        public string[] getInfo(int machitietbao)
        {
            string querybao = String.Format("Select TenBao,ThuPhatHanh,TenMauSac,TenViTri,GiaTienBao,CoHinhAnh,NgayBatDauPhatHanh from CHITIETBAO inner join VITRI on CHITIETBAO.MaViTri=VITRI.MaViTri inner join MAUSAC on CHITIETBAO.MaMauSac=MAUSAC.MaMauSac inner join BAO on BAO.MaBao=CHITIETBAO.MaBao inner join QCBAO on QCBAO.MaChiTietBao=CHITIETBAO.MaChiTietBao where CHITIETBAO.MaChiTietBao='{0}'", machitietbao);

           return new MyQueryDA().getArrValues(querybao);
        }

    }
}
